package com.wetao.lib_common.net.callback;

import android.content.Context;

import com.wetao.lib_common.Constants;
import com.wetao.lib_common.base.Base2Response;
import com.wetao.lib_common.base.BaseListResponse;
import com.wetao.lib_common.base.BaseResponse;
import com.wetao.lib_common.utils.DialogUtil;
import com.wetao.lib_common.utils.DialogXUtil;
import com.wetao.lib_common.utils.RestartBindUtils;


/**
 * @Package: com.yuanzong.lib_common.net.callback
 * @ClassName: RxReloginHandler
 * @Description: 作用描述
 * @Author: zhouyh
 * @OnCreate: 2019/4/22 2:14 PM
 */
public class RxReloginHandler implements ReLoginListener {



    private volatile static RxReloginHandler rxReloginHandler;

    private RxReloginHandler() {
    }

    public static RxReloginHandler getInstance() {
        if (rxReloginHandler == null) {
            synchronized (RxErrorHandler.class) {
                if (rxReloginHandler == null) {
                    rxReloginHandler = new RxReloginHandler();
                }
            }
        }
        return rxReloginHandler;
    }

    @Override
    public void handleRelogin(Context mContext, Object obejct) {
        if (obejct instanceof Base2Response)
        {
            Base2Response base2Response = (Base2Response) obejct;
            if (base2Response.getCode() == Constants.HTTP_ERROR.HTTP_TOKEN_OUT)
            {
//                RestartBindUtils.reBindDevice(mContext);
                DialogUtil.getInstance().reLoginDialog(mContext,"账号已在其他设备登录，\r\n请重新登录");
            }
        }else if (obejct instanceof BaseResponse)
        {
            BaseResponse baseResponse = (BaseResponse) obejct;
            if (baseResponse.getCode() == Constants.HTTP_ERROR.HTTP_TOKEN_OUT)
            {
//                RestartBindUtils.reBindDevice(mContext);
                DialogUtil.getInstance().reLoginDialog(mContext,"账号已在其他设备登录，\r\n请重新登录");
            }
        }else if (obejct instanceof BaseListResponse)
        {
            BaseListResponse baseResponse = (BaseListResponse) obejct;
            if (baseResponse.getCode() == Constants.HTTP_ERROR.HTTP_TOKEN_OUT)
            {
//                RestartBindUtils.reBindDevice(mContext);
                DialogUtil.getInstance().reLoginDialog(mContext,"账号已在其他设备登录，\r\n请重新登录");
            }
        }
    }
}
